$(function() {
	admin.deliverySysParam.init();
});
Namespace('admin.deliverySysParam', {
	init : function() {
		easyui.util.initDatagrid('#datagrid', {
			onDblClickRow : function() {
				/*var row = $('#datagrid').datagrid('getSelected');
				admin.supplier.edit(row.id);*/
			}
		});
	},
	query : function() {
		if (!$('#query-form').form('validate'))
			return;
		var data = $('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load', data);
	},
	toAdd : function() {
		top.addTab('#tabs','添加配送参数', contextPath+'/send/deliverySysParam/add');
	},
	edit:function(id) {
		if(id==null) {
			top.showInfo('请选择需要修改的记录!');
			return;
		}
		getDialog('data-dialog').dialog({
			href:contextPath+'/send/deliverySysParam/edit/'+id,
			title: '修改参数',
		    width: 500,
		    height: 450,
		    buttons:[{
				text:'确定',
				iconCls:'icon-ok',
				handler:function() {
					admin.deliverySysParam.doEdit();
				}
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#data-dialog').dialog('close');
				}
			}]
		});
	},
	doEdit:function() {
		if(!$('#data-form').form('validate')) return;
		var data=$('#data-form').form('jsonObject');
		$('#data-dialog').dialog('close');
		
		$('#datagrid').datagrid('loading');
		var row = $('#datagrid').datagrid('getSelected');
		$.post(contextPath+'/send/deliverySysParam/edit',data,function(result) {
			$('#datagrid').datagrid('loaded');
			if(result.code==1) {
				top.showInfo('修改成功!');
				$('#datagrid').datagrid('reload');
			} else {
				if (result.msg) {
					top.showInfo(result.msg);
				} else {
					top.showInfo('修改失败!');
				}
			}
		});
	}
});